package io;

import java.util.ArrayList;

import com.google.common.collect.HashBiMap;

/**
 * A collection of the data to be archived.
 * @author G'lek
 * @version 0.0.1
 */
public class DataLibrary {
    
    //ID, Data
    private HashBiMap<String, Data> data;
    
    public DataLibrary(){
        data = HashBiMap.create();
    }
    
    public void addDataEntry(String ID, Data d){
        data.put(ID, d);
        return;
    }
    
    public Data getData(String ID){
        return data.get(ID);
    }
    
    public String getID(Data d){
        return data.inverse().get(d);
    }
    
    public ArrayList<Data> getAllData(){
        ArrayList<Data> d = new ArrayList<Data>();
        d.addAll(data.values());
        return d;
    }
    
    public ArrayList<String> returnDataOfType(String type){
        ArrayList<String> IDs = new ArrayList<String>();
        for(Data d : data.values()){
            if(d.getType().equals(type)){
                IDs.add(data.inverse().get(d));
            }
        }
        return IDs;
    }
}
